const http=require('http');
const urlLib = require('url');
const queryStr = require('querystring');

http.createServer((req,res)=>{
  //获取get方法的数据
  let {pathname,query} = urlLib.parse(req.url,true);

  //获取post方法的数据
  let arr = [];
  req.on('data',data=>{
      arr.push(data);//接收数据 存在数组里
  });
  req.on('end',()=>{
    let post = queryStr.parse(Buffer.concat(arr).toString());
    console.log(pathname, query, post);
    res.write('asdfasdf');
    res.end();
  });
}).listen(8080);
